package com.xinzhi.utils;

import com.xinzhi.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Result {
    private String message;
    private Object data;
    private int code;

    public static Result success(User i){
        Map<String, Object> map = new HashMap<>();
        map.put("phone", i.getPhone());
        map.put("password",i.getPassword());
        String jwt = JwtUtils.generateJwt(map);

        return new Result("成功",jwt,200);
    }
    public static Result error(String msg){


        return new Result(msg,null,400);
    }
    public static Result videosuccess(Object data){
        return new Result("成功",data,200);
    }
}
